package group.igfd.manager.biz.utils;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;

public class JedisUtils {

    //本地
    public static String JEDIS_REQUEST_URL_LOCAL = "http://localhost:9966";
    //测试
    public static String JEDIS_REQUEST_URL_TEST = "http://api-test.bee.igfd.group";
    //正式
    public static String JEDIS_REQUEST_URL_PROD = "http://api.bee.igfd.group";

    public static String FLUSH_PUBLISH_BUYER_ADD_AND_UPDATE = "/api/Publish/buyer/flushPublishBuyerToEs";

    public static void addPublishBuyerToEs(String id) {
        String url = getUrl(FLUSH_PUBLISH_BUYER_ADD_AND_UPDATE);
        HttpRequest.sendPost(url,"id=" + id);
    }

    private static String getUrl(String urlSuff) {
        String activeProfile = SpringContextUtil.getActiveProfile();

        String url = null;
        if ("prod".equals(activeProfile)) {
            url = JEDIS_REQUEST_URL_PROD;
        } else if ("test".equals(activeProfile)) {
            url = JEDIS_REQUEST_URL_TEST;
        } else {
            url = JEDIS_REQUEST_URL_LOCAL;
        }

        return url + urlSuff;
    }

}
